/**
 * @file lwipopts.h
 * @author zdk
 * @brief 这个文件是LwIP的用户自定义配置，所有支持的配置以及它们的默认值都可以在opt.h文件中找到
 * @version 0.1
 * @date 2021-07-07
 * 
 * BSD 3-Clause License
 * 
 * Copyright (c) 2021, water_zhang
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 * 
 * * Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * 
 * * Neither the name of the copyright holder nor the names of its
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * 
 */

#if !defined(LWIPOPTS_H)
#define LWIPOPTS_H

/**
 * 轻量级的系统层移植，用于支持在多个上下文中同时使用lwip函数，
 * 比如没有操作系统时，在中断和主循环中同时调用API
 * 如果禁用这个可以减少移植的工作量，不过编程时就要避免在不同上
 * 下文中（比如中断）使用lwip函数。旧版本的lwip可能没有这个选项。
 */
#define SYS_LIGHTWEIGHT_PROT            (0)

#define MEMP_ALIGNMENT                  (4)                 /* 对于cortex-m4，内存为4字节对齐 */
#define MEM_SIZE                        (1024 * 30)         /* 定义给LWIP使用的堆大小 */

#define TCP_SND_BUF                     (4000)              /* 允许TCP协议使用的最大发送缓冲长度 */
#define TCP_MSS                         (1000)              /* TCP报文段最大长度 */

/* 以下用于控制调试打印信息的开关 */
#define NETIF_DEBUG                     LWIP_DBG_OFF        /* 网络接口层调试 */
#define ETHARP_DEBUG                    LWIP_DBG_OFF        /* ARP协议调试 */
#define ICMP_DEBUG                      LWIP_DBG_OFF        /* ICMP协议调试 */
#define IP_DEBUG                        LWIP_DBG_OFF        /* IP协议调试 */

/* 操作系统相关 */
#define NO_SYS                          (0)                 /* 提供操作系统支持 */
#define LWIP_SOCKET                     (1)                 /* 使用SOCKET接口，这个要操作系统支持 */
#define LWIP_NETCONN                    (1)                 /* 使用NETCONN接口，这个要操作系统支持 */
#define LWIP_COMPAT_MUTEX               (1)                 /* 由LwIP借助信号量自行实现互斥锁，但是这样就无法处理优先级反转问题了 */
#define LWIP_COMPAT_MUTEX_ALLOWED       (1)
#define TCPIP_MBOX_SIZE                 (sizeof(void *) * 100)
#define DEFAULT_RAW_RECVMBOX_SIZE       (sizeof(void *) * 5)
#define DEFAULT_UDP_RECVMBOX_SIZE       (sizeof(void *) * 5)
#define DEFAULT_TCP_RECVMBOX_SIZE       (sizeof(void *) * 5)
#define DEFAULT_ACCEPTMBOX_SIZE         (sizeof(void *) * 5)
#define TCPIP_THREAD_NAME               "tcpip_thread"
#define TCPIP_THREAD_STACKSIZE          (1024)
#define TCPIP_THREAD_PRIO               (3)
#endif // LWIPOPTS_H
